<template>
  <el-button
    type="text"
    size="small"
    v-clipboard:copy="value"
    v-clipboard:success="onCopy"
    v-clipboard:error="onError">
    {{btnText}}
  </el-button>
</template>
<script>
export default {
  props: {
    value: {
      type: [String, Number, Boolean],
      default: ''
    },
    btnText: {
      type: String,
      default: '复制'
    }
  },
  methods: {
    onCopy () {
      this.$message({ type: 'success', message: '复制成功' });
    },
    onError () {
      this.$message({ type: 'error', message: '复制失败' });
    }
  }
}
</script>
